const fs = require("fs")

//异步读取
fs.readFile('./input.txt',(err,data) => {
    if(err){
        console.log('读取失败')
        return
    }
    console.log(data.toString())
})

//同步读取
const data = fs.readFileSync('./output.txt')
console.log(data.toString())

const reader = fs.createReadStream('./input.txt')

reader.on('data',chunk => {
    console.log(chunk)
})

reader.on('end',() => {
    console.log('读取完成')
})